<template>
  <el-container class="layout-container-demo" style="height: 100vh">
    <el-aside width="200px" style="background: rgb(41,66,86)">
      <el-scrollbar>
        <Menu/>
      </el-scrollbar>
    </el-aside>

    <el-container>
      <el-header style="text-align: right; font-size: 12px; background-color: rgb(41,66,86); color: white;">
        <div class="toolbar">
          <el-dropdown style="height: 100%; display: inline-flex; justify-content: center; align-items: center; position: absolute; right: 20px;">
            <el-avatar
                src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
                size="small"
                shape="square"
            />
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item v-if="user">{{ user.username }}</el-dropdown-item>
              </el-dropdown-menu>
              <el-dropdown-menu>
                <el-dropdown-item @click="router.push('/login')">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>

      <el-main>
        <el-scrollbar>
          <router-view/>
        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>

import appStore from "../../store/appStore.ts";
import {ref} from "vue";
import router from "../../router";

const app = appStore()

const user = ref()

user.value = app.user


</script>

<style scoped>
.layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}
.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}
.layout-container-demo .el-menu {
  border-right: none;
}
.layout-container-demo .el-main {
  padding: 0;
}
.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
